
function closeWin() {
    var index = parent.location.reload();
    parent.layer.close(index);
}
/*定义提交订单的参数*/
var payModel = {};   //支付方式
var couponData;//返回的优惠券列表
var shippingAddressModel = {};//地址列表
var dispatchBillModel = {};//商品列表
var couponModel = null; //优惠券列表
var customerPhoneExist = "";//在档电话验证
var tradeUuid = "";//订单唯一标示
var pageData = {};//保存showOrderPageInfo接口返回的数据
var invalidData = {};//商品列表数据变量，保存失效商品用
var customerInfo = JSON.parse(window.sessionStorage.getItem("customerInfo"));
var phoneData = JSON.parse(window.sessionStorage.getItem("phoneData"));
// var firstAddressData = {};

var json = {};
var g = {};

var isIng = false;//防止重复提交
var addressList = {};//保存实时地址列表
var shipAddId = "";
var shoppingAddList = {};
var freightIsChange = false;//判断是否修改运费
//展开地址
function moreAddress() {
    $(".address_info").addClass("address_info_down");
    $("#more").attr("class", "hidden");
    $("#less").attr("class", "lessAdd")
}

//收起地址
function lessAddress() {
    console.log(shipAddId)
    $(".address_info").html('');
    var optionstring = "";
    for (var i = 0; i < addressList.length; i++) {
        var obj = addressList[i];
        var streetName = '';
        if (obj.street_id == 0) {
            obj.streetName = streetName;
        }

        //----------名字拼接显示开始-----------
        var nameList = "";
        var moblieList = "";
        var personList = obj.addressPersonList;
        if (personList != null && personList.length > 0) {
            for (var j = 0; j < personList.length; j++) {
                if (personList.length > 1) {
                    nameList += personList[j].receiverName + ";";//姓名拼接
                    var mobile = personList[j].mobile;
                    moblieList = mobile.substr(0, 3) + "XXXX" + mobile.substr(7) + " ...";
                } else {
                    nameList += personList[j].receiverName;//姓名拼接
                    var mobile = personList[j].mobile;
                    moblieList = mobile.substr(0, 3) + "XXXX" + mobile.substr(7);
                }
                var mobile = personList[j].mobile;
                var receiverId = personList[j].receiverId;


            }
        }
        if (obj.is_default == 1 && Number(obj.ship_add_id) == Number(shipAddId)) {
            console.log(456)
            optionstring += '<div class="mb-5 ml-20 addressSelected" style="float: left;position: relative; height: 30px;width: 90%;" onclick="selectAddress(this)"><span class="hide" id="addressname">' + obj.add_alias + '</span><span class="hidden"  id="use_name_str">' + linkman + '</span><span class="address_name"  id="usename" style="text-align: center;">' + nameList + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + obj.provinceName + '</span><span class="address_detail" id="addressdetail">' + obj.provinceName + obj.cityName + obj.areaName + obj.streetName + obj.detail_address + '</span><span class="user_phone" style="display:inline-block;line-height: 30px;color:#fff;background: #999;padding:0 5px;text-align: center;">默认地址</span><span class="hidden" id="addDetail">' + obj.detail_address + '</span><span class="hidden" id="celephone">' + mobile +'</span><span class="hide" id="receiverId">' + receiverId +'</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="DeleteAddress(this)" >删除</a></span></div>'
        } else if (Number(obj.ship_add_id) == Number(shipAddId)) {
            console.log(123)
            optionstring += '<div class="mb-5 ml-20 addressSelected" style="float: left;position: relative; height: 30px;width: 90%;" onclick="selectAddress(this)"><span class="hide" id="addressname">' + obj.add_alias + '</span><span class="hidden"  id="use_name_str">' + linkman + '</span><span class="address_name"  id="usename" style="text-align: center;">' + nameList + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + obj.provinceName + '</span><span class="address_detail" id="addressdetail">' + obj.provinceName + obj.cityName + obj.areaName + obj.streetName + obj.detail_address + '</span><span class="user_phone" id="userphone">' + moblieList + '</span><span class="hidden" id="addDetail">' + obj.detail_address + '</span><span class="hidden" id="celephone">' + mobile +'</span><span class="hide" id="receiverId">' + receiverId +'</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="DeleteAddress(this)" >删除</a></span></div>'
        }
    }
    /*----------------------------------------------------------------*/
    for (var i = 0; i < addressList.length; i++) {
        var obj = addressList[i];
        var streetName = '';
        if (obj.street_id == 0) {
            obj.streetName = streetName;
        }

        //----------名字拼接显示开始-----------
        var nameList = "";
        var moblieList = "";
        var personList = obj.addressPersonList;
        if (personList != null && personList.length > 0) {
            for (var j = 0; j < personList.length; j++) {
                if (personList.length > 1) {
                    nameList += personList[j].receiverName + ";";//姓名拼接
                    var mobile = personList[j].mobile;
                    moblieList = mobile.substr(0, 3) + "XXXX" + mobile.substr(7) + " ...";
                } else {
                    nameList += personList[j].receiverName;//姓名拼接
                    var mobile = personList[j].mobile;
                    moblieList = mobile.substr(0, 3) + "XXXX" + mobile.substr(7);
                }
                var mobile = personList[j].mobile;
                var receiverId = personList[j].receiverId;


            }
        }

        if (obj.is_default == 1) {
            optionstring += '<div class="mb-5 ml-20" style="float: left;position: relative; height: 30px;width: 90%;" onclick="selectAddress(this)"><span class="hide" id="addressname">' + obj.add_alias + '</span><span class="hidden"  id="use_name_str">' + linkman + '</span><span class="address_name"  id="usename" style="text-align: center;">' + nameList + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + obj.provinceName + '</span><span class="address_detail" id="addressdetail">' + obj.provinceName + obj.cityName + obj.areaName + obj.streetName + obj.detail_address + '</span><span class="user_phone" style="display:inline-block;line-height: 30px;color:#fff;background: #999;padding:0 5px;text-align: center;">默认地址</span><span class="hidden" id="addDetail">' + obj.detail_address + '</span><span class="hidden" id="celephone">' + mobile +'</span><span class="hide" id="receiverId">' + receiverId +'</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="DeleteAddress(this)" >删除</a></span></div>'
        } else {
            optionstring += '<div class="mb-5 ml-20" style="float: left;position: relative; height: 30px;width: 90%;" onclick="selectAddress(this)"><span class="hide" id="addressname">' + obj.add_alias + '</span><span class="hidden"  id="use_name_str">' + linkman + '</span><span class="address_name"  id="usename" style="text-align: center;">' + nameList + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + obj.provinceName + '</span><span class="address_detail" id="addressdetail">' + obj.provinceName + obj.cityName + obj.areaName + obj.streetName + obj.detail_address + '</span><span class="user_phone" id="userphone">' + moblieList + '</span><span class="hidden" id="addDetail">' + obj.detail_address + '</span><span class="hidden" id="celephone">' + mobile +'</span><span class="hide" id="receiverId">' + receiverId +'</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="DeleteAddress(this)" >删除</a></span></div>'
        }
    }
    $(".address_info").html("<div id='ss' style='color: #cc0000'></div>" + optionstring);

    $(".address_info").removeClass("address_info_down");
    $("#less").attr("class", "hidden");
    $("#more").attr("class", "lessAdd");
}

// $(this);

// 选择地址
function selectAddress(el) {
    var optionstring = '';
    shipAddId = $(el).find('#ship_add_id').html();
    console.log(shipAddId)
    // optionstring = '<div class="mb-5 ml-20 addressSelected" style="height: 80px;float: left;position: relative;" onclick="selectAddress(this)">'+$(el).html()+'</div>';
    /*for(var i = 0; i < addressList.length; i++){
        var obj = addressList[i];
        var personList = obj.addressPersonList;
        if(personList != null && personList.length > 0){
            console.log(addressList);
            console.log(personList);
            var nameList = "";
            var moblieList = "";
            for (var j = 0; j < personList.length; j++) {
                var sub = personList[j].mobile.substr(3, 4);
                sub = sub.replace(sub, 'XXXX');
                if(j < personList.length){
                    nameList += personList[j].receiverName +" ; ";
                    moblieList += sub +" ; ";
                }
                if(j == personList.length-1){
                    nameList += personList[j].receiverName;
                    moblieList += sub;
                }
            }
            if(obj.ship_add_id != $(el).find("#ship_add_id").html()){
                optionstring += '<div class="mb-5 ml-20" style="height: 80px;float: left;position: relative;" onclick="selectAddress(this)"><span class="hide" id="addressname">' + obj.add_alias + '</span><span class="user_name"  id="usename">' + nameList + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + obj.provinceName + '</span><span class="address_detail"  id="addressdetail">' + obj.provinceName + obj.cityName + obj.areaName + obj.streetName + obj.detail_address + '</span><span class="user_phone" id="userphone">' + moblieList + '</span><span class="hidden" id="addDetail">' + obj.detail_address + '</span><span class="hidden" id="celephone">' + obj.mobile + '</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="receiverId">' + obj.addressPersonList[0].receiverId +'</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="DeleteAddress(this)" >删除</a></span></div>'
            }
        }
    }
    $(".address_info").html("<div id='ss' style='color: #cc0000'></div>"+optionstring);
    $(".address_info").animate({scrollTop:0},10);*/
    // lessAddress();
    $(el).addClass("addressSelected")
    for(var i=0;i<$(el).siblings().length;i++){
        $($(el).siblings()[i]).removeClass("addressSelected");
        // $(el).siblings()[i].firstChild.style.border = "0px solid red";
    }
    // el.firstChild.style.border = "1px solid red";
    // var optionstring = "";
    // var morendizhi = ""
    // $("#defaultAddress").val("");
    // morendizhi = '<span id="defaultAddress">' + '默认地址' + '</span>';
    // optionstring = '<div class="mb-5 ml-20 addressSelected" style="height: 80px;float: left;position: relative;" onclick="selectAddress(this)">'+ $(el).html()+'</div>';
    // console.log(morendizhi);
    // console.log(optionstring);
    // for (var i = 0; i < addressList.length; i++) {
    //     var obj = addressList[i];
    //     console.log(obj)
    //
    //     //名字拼接显示
    //     if (obj.addressPersonList != null && obj.addressPersonList != "") {
    //
    //         var nameList = ""
    //         for (var j = 0; j < obj.addressPersonList.length; j++) {
    //             if (obj.addressPersonList.length > 1) {
    //                 for (var j = 0; j < obj.addressPersonList.length; j++) {
    //                     var PersonList = obj.addressPersonList;
    //                     //----------名字拼接显示开始-----------
    //                     if (j < obj.addressPersonList.length) {
    //                         nameList += PersonList[j].receiverName + " ; ";
    //                     } else if (j == obj.addressPersonList.length - 1) {
    //                         nameList += PersonList[j].receiverName;
    //                     }
    //                     //----------名字拼接显示结束-----------
    //                     console.log(PersonList)
    //                     var linkman = PersonList[j].receiverName;
    //                     var mobile = PersonList[j].mobile;
    //                     console.log(mobile);
    //                     if (mobile != "" && mobile != null) {
    //                         var sub = mobile.substr(3, 4);
    //                         mobile = mobile.replace(sub, 'XXXX');
    //                     } else {
    //                         mobile = "";
    //                     }
    //                     if (obj.ship_add_id != $(el).find("#ship_add_id").html()) {
    //                         optionstring += '<div class="mb-5 ml-20" style="height: 80px;float: left;position: relative;" onclick="selectAddress(this)"><span class="hide" id="addressname">' + obj.add_alias + '</span><span class="hidden"  id="use_name_str">' + linkman + '</span><span class="user_name"  id="usename">' + nameList + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + obj.provinceName + '</span><span class="address_detail"  id="addressdetail">' + obj.provinceName + obj.cityName + obj.areaName + obj.streetName + obj.detail_address + '</span><span class="user_phone" id="userphone">' + mobile + '</span><span class="hidden" id="addDetail">' + obj.detail_address + '</span><span class="hidden" id="celephone">' + obj.addressPersonList[j].mobile + '</span><span class="hide" id="receiverId">' + obj.addressPersonList[j].receiverId + '</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="DeleteAddress(this)" >删除</a></span></div>'
    //                     }
    //                 }
    //             }
    //         }
    //     }
    // }
    // $(".address_info").html("<div id='ss' style='color: #cc0000'></div>" + optionstring);
    // $("#defaultAddress").val("");
    // $(".address_info").animate({scrollTop: 0}, 10);
    // lessAddress();
    // $(el).removeClass("addressSelected");
    // $(el).addClass("addressSelected");
    // for (var i = 0; i < $(el).siblings().length; i++) {
    //     $($(el).siblings()[i]).removeClass("addressSelected");
    //     $(el).siblings()[i].firstChild.style.border = "0px solid red";
    // }

    // el.firstChild.style.border = "1px solid red";
    /*firstAddressData = {
        addressName: $(el).context.childNodes[0].innerHTML,
        userName: $(el).context.childNodes[1].innerHTML,
        addressDetail: $(el).context.childNodes[2].innerHTML,
        userPhone: $(el).context.childNodes[3].innerHTML,
        addDetail: $(el).context.childNodes[4].innerHTML,
        celephone: $(el).context.childNodes[5].innerHTML,
        shipAddressId: $(el).context.childNodes[6].innerHTML,
        customerEmail: $(el).context.childNodes[7].innerHTML,
        customerLandlinePhone: $(el).context.childNodes[8].innerHTML,
    }
    console.log(firstAddressData)*/
}
//展开商品
function moreProduct() {
    $("#many").attr("class", "hidden");
    $("#little").attr("class", "lessAdd");
    var tradeBoxItems = JSON.parse(window.sessionStorage.getItem("tradeBoxItems"));
    if (tradeBoxItems != "") {
        var optionstring = "";
        for (var i = 0; i < tradeBoxItems.length; i++) {
            var obj = tradeBoxItems[i];
            var sub_price = obj.purchaseCount * obj.salePrice;
            optionstring += "<tr><td class='info'><span class='info_img'><img src='" + obj.skuSpuImgUrl + "' id='" + obj.skuId + "," + obj.spuId + "'></span><span class='info_text'>" + obj.spuName + "</span></td><td><span class='model'>" + obj.skuInfo + "</span> X <span class='number' style='float: none'>" + obj.purchaseCount + "</span></td><td class='price'>¥<input class='input-text radius w-60 ml-5 s' type='text' readonly='readonly' value="+obj.salePrice+" id='inputshow' style='width: 88px; border: solid 1px #FFFFFF'/>&nbsp;&nbsp;&nbsp;<input type='button' class='ButtonTrue' data-top='"+obj.salePrice+"'  style='display:none' id='buttonshow' onclick='ChangeTrue(this)' value='保存'><p class='pbiaoqian' style='  margin-top:-2px;height:0px;font-size=1px'></p></td><td class='sub_price'>¥" + sub_price.toFixed(2) + "</td><td class='operate'>有货</td><td class='hide'>" + obj.skuId + "</td></tr>";
        }
        $(".goods_table").html(optionstring);
    }
}

//收起商品
function lessProduct() {
    $("#little").attr("class", "hidden");
    $("#many").attr("class", "lessAdd");
    var tradeBoxItems = JSON.parse(window.sessionStorage.getItem("tradeBoxItems"));
    if (tradeBoxItems != "") {
        var optionstring = "";
        for (var i = 0; i < 5; i++) {
            var obj = tradeBoxItems[i];
            var sub_price = obj.purchaseCount * obj.salePrice;
            optionstring += "<tr><td class='info'><span class='info_img'><img src='" + obj.skuSpuImgUrl + "' id='" + obj.skuId + "," + obj.spuId + "'></span><span class='info_text'>" + obj.spuName + "</span></td><td><span class='model'>" + obj.skuInfo + "</span> X <span class='number' style='float: none'>" + obj.purchaseCount + "</span></td><td class='price'>¥<input class='input-text radius w-60 ml-5 s' type='text' readonly='readonly' value="+obj.salePrice+" id='inputshow' style='width: 88px; border: solid 1px #FFFFFF'/>&nbsp;&nbsp;&nbsp;<input type='button' class='ButtonTrue' data-top='"+obj.salePrice+"'  style='display:none' id='buttonshow' onclick='ChangeTrue(this)' value='保存'><p class='pbiaoqian' style='  margin-top:-2px;height:0px;font-size=1px'></p></td><td class='sub_price'>¥" + sub_price.toFixed(2) + "</td><td class='operate'>有货</td><td class='hide'>" + obj.skuId + "</td></tr>";
        }
        $(".goods_table").html(optionstring);
    }
}

/*--------------------------------------------计算运费函数开始-----------------------------------------*/
function calculateFare(Discountedprice, AmountGoods) {
    if (Discountedprice >= AmountGoods) {
        $.ajax({
            type: 'post',
            url: root.replaceInter.replace_getShippingAddressInfo,
            dataType: 'json',
            data: JSON.stringify({goodTotalMoney: AmountGoods}),
            contentType: 'application/json',
            success: function (data) {
                if (data.errorCode == 0) {
                    $("#yunfei").html((Number(data.freight)).toFixed(2));
                    $("#youhuijuan").html(Number(AmountGoods).toFixed(2));
                    $("#zongjine").html((Number(data.freight)).toFixed(2));
                    $("#couponNum").html(1);
                    $("#actualVal").html(Number(AmountGoods).toFixed(2));
                    console.log($(".on_uncheck").find("#couponCode").length)
                    if ($(".on_uncheck").find("#couponCode").length == 0) {
                        couponModel = null;
                    } else {
                        var couponCode = $(".on_uncheck").find("#couponCode")[0].innerHTML;
                        console.log(couponData)
                        for (var i = 0; i < couponData.length; i++) {
                            /*优惠券拼装*/
                            if (couponCode == couponData[i].couponCode) {
                                console.log(couponData[i].couponCode)
                                couponModel = {
                                    "couponCode": couponData[i].couponCode,//优惠券编码
                                    "couponDesc": couponData[i].couponDesc,//"优惠券描述",
                                    "couponRealValue": couponData[i].couponRealValue,//优惠券实际金额  满多少
                                    "couponScope": couponData[i].couponScope,//优惠券适用范围
                                    "couponSkuModelList": couponData[i].spuSkuBoList,//优惠券使用商品列表
                                    "couponType": couponData[i].couponType,//优惠券类型
                                    "couponOffsetValue": couponData[i].couponValue,//优惠券可以抵扣的金额(原优惠券配置的可以抵用的金额)
                                    "couponValue": Number(AmountGoods).toFixed(2),//优惠券 抵用的金额 实际使用的金额(若商品金额小于抵用金额,取商品金额)
                                }
                            }

                        }
                    }
                } else {
                    $.Huimodalalert(data.errorMessage, 2000);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
            }
        });
    } else {
        $.ajax({
            type: 'post',
            url: root.replaceInter.replace_getShippingAddressInfo,
            dataType: 'json',
            data: JSON.stringify({goodTotalMoney: AmountGoods - Discountedprice}),
            contentType: 'application/json',
            success: function (data) {
                if (data.errorCode == 0) {
                    $("#yunfei").html((Number(data.freight)).toFixed(2));
                    $("#youhuijuan").html(Number(Discountedprice).toFixed(2));
                    $("#zongjine").html((Number(data.freight) + Number(AmountGoods) - Number(Discountedprice)).toFixed(2));
                    $("#couponNum").html(1);
                    $("#actualVal").html(Number(Discountedprice).toFixed(2));
                    if ($(".on_uncheck").find("#couponCode").length == 0) {
                        couponModel = null;
                    } else {
                        var couponCode = $(".on_uncheck").find("#couponCode")[0].innerHTML;
                        for (var i = 0; i < couponData.length; i++) {
                            /*优惠券拼装*/
                            if (couponCode == couponData[i].couponCode) {
                                /*优惠券拼装*/
                                couponModel = {
                                    "couponCode": couponData[i].couponCode,//优惠券编码
                                    "couponDesc": couponData[i].couponDesc,//"优惠券描述",
                                    "couponRealValue": couponData[i].couponRealValue,//优惠券实际金额  满多少
                                    "couponScope": couponData[i].couponScope,//优惠券适用范围
                                    "couponSkuModelList": couponData[i].spuSkuBoList,//优惠券使用商品列表
                                    "couponType": couponData[i].couponType,//优惠券类型
                                    "couponOffsetValue": couponData[i].couponValue,//优惠券可以抵扣的金额(原优惠券配置的可以抵用的金额)
                                    "couponValue": couponData[i].couponValue,//优惠券 抵用的金额 实际使用的金额(若商品金额小于抵用金额,取商品金额)
                                }
                            }
                        }
                        console.log(couponModel)
                    }

                } else {
                    $.Huimodalalert(data.errorMessage, 2000);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
            }
        });
    }
}

/*--------------------------------------------计算运费函数结束-----------------------------------------*/

/*-----------------------------优惠券部分-----------------------------*/
function renderCoupon(data) {
    couponData = data.couponSpuSkuBoList;
    var couponStr = "";
    // console.log(couponData)
    if (couponData == undefined) {
        couponModel = null;
    } else {
        for (var i = 0; i < couponData.length; i++) {
            var endTime = (couponData[i].useEndtime).slice(0, 10);
            if (data.couponCode == couponData[i].couponCode) {
                couponStr += '<div class="coupon_list_box on_uncheck" onclick="chooseCoupon(this)"><div class="Uncheck uncheak1" style="display: block;"  onclick="cancelChoose(this,event)">取消勾选</div><div class="beijing3"><div class="money">¥<span style="float: none;margin-right: 0" id="DiscountedPrice">' + couponData[i].couponValue + '</span></div><div class="useConditions">满' + couponData[i].couponRealValue + '使用</div><div class="Validityperiod">有效期至' + endTime + '</div></div><div class="beijing3down" ><span>[限平台限品类]</span><span id="couponCode" class="hide">' + couponData[i].couponCode + '</span></div></div>';
                $("#youhuijuan").html(Number(data.couponOffset).toFixed(2));
                if ($("#youhuijuan").html()=='0.00'){
                    //如果优惠券为0，显示改价按钮
                    $("#changeprice").show();
                }else{
                    $("#changeprice").hide();
                }
                if (couponData[i].couponValue >= data.goodTotalMoney) {
                    /*优惠券拼装*/
                    couponModel = {
                        "couponCode": couponData[i].couponCode,//优惠券编码
                        "couponDesc": couponData[i].couponDesc,//"优惠券描述",
                        "couponRealValue": couponData[i].couponRealValue,//优惠券实际金额  满多少
                        "couponScope": couponData[i].couponScope,//优惠券适用范围
                        "couponSkuModelList": couponData[i].spuSkuBoList,//优惠券使用商品列表
                        "couponType": couponData[i].couponType,//优惠券类型
                        "couponOffsetValue": couponData[i].couponValue,//优惠券可以抵扣的金额(原优惠券配置的可以抵用的金额)
                        "couponValue": data.goodTotalMoney,//优惠券 抵用的金额 实际使用的金额(若商品金额小于抵用金额,取商品金额)
                    }
                } else {
                    /*优惠券拼装*/
                    couponModel = {
                        "couponCode": couponData[i].couponCode,//优惠券编码
                        "couponDesc": couponData[i].couponDesc,//"优惠券描述",
                        "couponRealValue": couponData[i].couponRealValue,//优惠券实际金额  满多少
                        "couponScope": couponData[i].couponScope,//优惠券适用范围
                        "couponSkuModelList": couponData[i].spuSkuBoList,//优惠券使用商品列表
                        "couponType": couponData[i].couponType,//优惠券类型
                        "couponOffsetValue": couponData[i].couponValue,//优惠券可以抵扣的金额(原优惠券配置的可以抵用的金额)
                        "couponValue": couponData[i].couponValue,//优惠券 抵用的金额 实际使用的金额(若商品金额小于抵用金额,取商品金额)
                    }
                }
            } else {
                if (couponData[i].couponUseStatus == 0) {
                    couponStr += '<div class="coupon_list_box" onclick="chooseCoupon(this)"><div class="Uncheck uncheak1" onclick="cancelChoose(this,event)" >取消勾选</div><div class="beijing3"><div class="money">¥<span style="float: none;margin-right: 0" id="DiscountedPrice">' + couponData[i].couponValue + '</span></div><div class="useConditions">满' + couponData[i].couponRealValue + '使用</div><div class="Validityperiod">有效期至' + endTime + '</div></div><div class="beijing3down" ><span>[限平台限品类]</span><span id="couponCode" class="hide">' + couponData[i].couponCode + '</span></div></div>';
                } else {
                    couponStr += '<div class="coupon_list_box"><div class="beijing5" style="float: none;"><div class="money">¥' + couponData[i].couponValue + '</div><div class="useConditions">满' + couponData[i].couponRealValue + '使用</div><div class="Validityperiod">有效期至' + endTime + '</div></div><div class="beijing5down">[限平台限品类]</div><span id="couponCode" class="hide">' + couponData[i].couponCode + '</span></div>';
                }
            }
        }
        $("#beijing1").html(couponStr + '<div class="beijing3_info">金额抵用<span class="yhq_text" id="actualVal">' + Number(data.couponOffset).toFixed(2) + '</span>优惠券<span id="couponNum">1</span>张</div>');
    }
}
/*选择优惠券*/
function chooseCoupon(el) {
    $("#yunfei-afterChange").html("");//清空运费
    $("#afterFare-remark").html("");//清空缓存
    $(".uncheak1").css("display", "none");
    $(el).addClass("on_uncheck");
    for (var i = 0; i < $(el).siblings().length + 1; i++) {
        $($(el).siblings()[i]).removeClass("on_uncheck");
    }
    $(el).find(".uncheak1").css("display", "block");

    var Discountedprice = $("#DiscountedPrice").html(); //优惠券抵扣金额
    var AmountGoods = $(".good_total_price").html(); //商品总额
    if (!freightIsChange) {
        calculateFare(Number(Discountedprice), Number(AmountGoods));//运费计算
    }
    if (Number(Discountedprice) >= Number(AmountGoods)) {
        $("#youhuijuan").html(Number(AmountGoods).toFixed(2));
        $("#zongjine").html(Number($("#yunfei").html()).toFixed(2));
        $("#couponNum").html(1);
        $("#actualVal").html(Number(AmountGoods).toFixed(2));
    } else {
        $("#youhuijuan").html(Number(Discountedprice).toFixed(2));
        $("#zongjine").html((Number($("#yunfei").html()) + Number(AmountGoods) - Number(Discountedprice)).toFixed(2));
        $("#couponNum").html(1);
        $("#actualVal").html(Number(Discountedprice).toFixed(2));
    }
    if ($("#youhuijuan").html()=='0.00'){
        //如果优惠券为0，显示改价按钮
        $("#changeprice").show();
    }else{
        $("#changeprice").hide();
    }
}

/*取消选择优惠券*/
function cancelChoose(el, e) {
    e.stopPropagation();   //组织冒泡
    $("#yunfei-afterChange").html("");//清空运费
    $("#afterFare-remark").html("");//清空缓存
    $(el.parentElement).removeClass("on_uncheck");
    $(el).css("display", "none");
    var AmountGoods = $(".good_total_price").html();//商品总额
    if (!freightIsChange) {
        $.ajax({
            type: 'post',
            url: root.replaceInter.replace_getShippingAddressInfo,
            dataType: 'json',
            data: JSON.stringify({goodTotalMoney: Number(AmountGoods)}),
            contentType: 'application/json',
            success: function (data) {
                if (data.errorCode == 0) {
                    $("#yunfei").html((Number(data.freight)).toFixed(2));
                    $("#youhuijuan").html("0.00");
                    $("#zongjine").html((Number(data.freight) + Number(AmountGoods)).toFixed(2));
                    $("#couponNum").html(0);
                    $("#actualVal").html(0.00);
                    couponModel = null;
                } else {
                    $.Huimodalalert(data.errorMessage, 2000);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
            }
        });
    }
    $("#youhuijuan").html("0.00");
    $("#zongjine").html((Number($("#yunfei").html()) + Number(AmountGoods)).toFixed(2));
    $("#couponNum").html(0);
    $("#actualVal").html(0.00);
    if ($("#youhuijuan").html()=='0.00'){
        //如果优惠券为0，显示改价按钮
        $("#changeprice").show();
    }else{
        $("#changeprice").hide();
    }
}
/*-----------------------------优惠券部分结束-----------------------------*/
/*-----------------------------商品列表渲染及商品数据拼装开始-----------------------------*/

//isClearRender为true，清除失效后渲染，为false：加载渲染
function renderGoodsList(data, isClearRender) {
    var couponData = data.couponSpuSkuBoList;
    var myTime = new Date().getTime();
    var time = format(myTime + Number(data.mayArrivedIn) * 24 * 60 * 60 * 1500);
    var m = time.split(" ")[0].split("-")[1];
    var d = time.split(" ")[0].split("-")[2];
    $(".deliverytime").html("配送时间：次日达，预计" + m + "月" + d + "能送到您的手里。"); //配送时间
    if (isClearRender == false) {
        var goodTotalWeight = data.goodTotalWeight;
        $(".weight").html("总重量：" + Number(goodTotalWeight).toFixed(2) + "公斤"); //总重量
    } else {
        if ($(".on_uncheck").find("#DiscountedPrice").length == 0) {
            var couponValue = 0;//优惠券抵扣金额
        } else {
            var couponValue = $(".on_uncheck").find("#DiscountedPrice")[0].innerHTML;//优惠券抵扣金额
        }
        var goodTotalWeight = 0; //总重量
        var goodsTotal = 0; //商品总额
        var totalCount = 0; //商品总额
        for (var i = 0; i < data.tradeBoxItems.length; i++) {
            goodTotalWeight += Number(data.tradeBoxItems[i].purchaseCount) * Number(data.tradeBoxItems[i].skuWeight);//删除失效商品后的总重量计算
            goodsTotal += Number(data.tradeBoxItems[i].purchaseCount) * Number(data.tradeBoxItems[i].salePrice);// 删除失效商品后的总额计算
            totalCount += Number(data.tradeBoxItems[i].purchaseCount);// 删除失效商品后的总数量计算
        }
        $(".weight").html("总重量：" + Number(goodTotalWeight).toFixed(2) + "公斤"); //总重量
        $(".good_total_price").html(Number(goodsTotal).toFixed(2)); //商品总价
        $(".goods_total_count").html(totalCount); //总商品数量
        if (!freightIsChange) {
            calculateFare(Number(couponValue), Number(goodsTotal));//运费计算
        }
    }

    window.sessionStorage.setItem("tradeBoxItems", JSON.stringify(data.tradeBoxItems));

    var skuModelList = [];  //商品列表数组，保存提交的商品
    if (data.tradeBoxItems != "") {
        var items = data.tradeBoxItems;
        var optionstring = "";
        if (items.length > 5) {
            for (var i = 0; i < 5; i++) {
                var obj = items[i];
                var sub_price = obj.purchaseCount * obj.salePrice;
                optionstring += "<tr><td class='info'><span class='info_img'><img src='" + obj.skuSpuImgUrl + "' id='" + obj.skuId + "," + obj.spuId + "'></span><span class='info_text'>" + obj.spuName + "</span></td><td><span class='model'>" + obj.skuInfo + "</span> X <span class='number' style='float: none'>" + obj.purchaseCount + "</span></td><td class='price'>¥<input class='input-text radius w-60 ml-5 s' type='text' readonly='readonly' value="+obj.salePrice+" id='inputshow' style='width: 88px; border: solid 1px #FFFFFF'/>&nbsp;&nbsp;&nbsp;<input type='button' class='ButtonTrue' data-top='"+obj.salePrice+"'  style='display:none' id='buttonshow' onclick='ChangeTrue(this)' value='保存'><p class='pbiaoqian' style='  margin-top:-2px;height:0px;font-size=1px'></p></td><td class='sub_price'>¥" + sub_price.toFixed(2) + "</td><td class='operate'>有货</td><td class='hide'>" + obj.skuId + "</td></tr>";
            }
            for (var i = 0; i < items.length; i++) {
                var obj = items[i];
                var skuOneModel = {
                    buyyerCount: obj.purchaseCount,
                    productName: obj.spuName,
                    productPic: obj.skuSpuImgUrl,
                    salePrice: obj.salePrice,
                    skuId: obj.skuId,
                    skuInfo: obj.skuInfo,
                    spuId: obj.spuId,
                };
                skuModelList.push(skuOneModel);
            }
        } else {
            for (var i = 0; i < items.length; i++) {
                var obj = items[i];
                var sub_price = obj.purchaseCount * obj.salePrice;
                optionstring += "<tr><td class='info'><span class='info_img'><img src='" + obj.skuSpuImgUrl + "' id='" + obj.skuId + "," + obj.spuId + "'></span><span class='info_text'>" + obj.spuName + "</span></td><td><span class='model'>" + obj.skuInfo + "</span> X <span class='number' style='float: none'>" + obj.purchaseCount + "</span></td>" +
                    "<td class='price'>¥<input class='input-text radius w-60 ml-5 s' type='text' readonly='readonly' value="+obj.salePrice+" id='inputshow' style='width: 88px; border: solid 1px #FFFFFF'/>&nbsp;&nbsp;&nbsp;<input type='button' class='ButtonTrue' data-top='"+obj.salePrice+"'  style='display:none' id='buttonshow' onclick='ChangeTrue(this)' value='保存'><p class='pbiaoqian' style='  margin-top:-2px;height:0px;font-size=1px'></p></td>" +
                    "<td class='sub_price'>¥" + sub_price.toFixed(2) + "</td><td class='operate'>有货</td><td class='hide'>" + obj.skuId + "</td></tr>";
                var skuOneModel = {
                    buyyerCount: obj.purchaseCount,
                    productName: obj.spuName,
                    productPic: obj.skuSpuImgUrl,
                    salePrice: obj.salePrice,
                    skuId: obj.skuId,
                    skuInfo: obj.skuInfo,
                    spuId: obj.spuId,
                };
                skuModelList.push(skuOneModel);
            }
        }

        $(".goods_table").html(optionstring);

        if (items.length < 6) {
            $(".isUnfold").hide()
        }
    }

    /* 商品列表 */
    dispatchBillModel = {
        mayArrivedIn: data.mayArrivedIn,
        mayArrivedDay: time,
        totalWeight: Number(data.goodTotalWeight).toFixed(2)
    };
    dispatchBillModel.skuModelList = skuModelList;
}
function ChangeTrue(el) {
    var price=Number($(el).parents('tr').find('.s').val())
    var oldPrice=Number($(el).parents('tr').find('.ButtonTrue').attr("data-top"))
    if (price/oldPrice<0.7){
        $(el).parents('td').find('.pbiaoqian').html('超过下限!')
        if (price/oldPrice<=0.5){
            $(el).parents('td').find('.pbiaoqian').html('超过成本价!')
        }
        $(el).parents('td').find('.pbiaoqian').css('color','red')
    }else if (price/oldPrice>1.3){
        $(el).parents('td').find('.pbiaoqian').html('超过上限!')
        $(el).parents('td').find('.pbiaoqian').css('color','red')
    }else{
        $(el).parents('td').find('.pbiaoqian').html('')
        $(el).parents('td').find('.pbiaoqian').css('color','')
    }
}
/*改价*/
function ChangePrice() {
    //使优惠券不可点击
    $(".coupon_list_box").removeAttr("onclick");
    //button
    $(".ButtonTrue").show()
    //input
    $('.s').removeAttr("readonly");
}
/*-----------------------------商品列表渲染及商品数据拼装结束-----------------------------*/
getInfo();
var shipAdd = "";

function getInfo() {
    if (phoneData != null && phoneData != "") {
        if (phoneData.customerCode != "" && phoneData.customerCode == customerInfo.customerCode) {
            $("#phonenumber").val(phoneData.mobilePhone);
            $.ajax({
                type: 'post',
                url: root.replaceInter.replace_adminCheckArchivalPhone,
                dataType: 'json',
                data: phoneData,//需要将当前的对象转换为json字符串,
                success: function (data) {
                    if (data.errorCode == 0) {
                        customerPhoneExist = 10;
                        $("#verify").html("<div id='verifyState' class='verify yes'><span style='margin-left: 25px'><img src='../../../img/smallsuccess.png' class='w-11 h-11'></span><span style='margin-left:-14px;color:#04BE02 '>是</span></div>")
                        window.sessionStorage.setItem("phoneData", JSON.stringify(phoneData));
                    } else {
                        customerPhoneExist = 20;
                        $("#verify").html("<div id='verifyState' class='verify no'><span style='margin-left: 25px'><img src='../../../img/false.png' class='w-11 h-11' ></span><span style='margin-left:-14px '>否</span></div>")
                        window.sessionStorage.setItem("phoneData", JSON.stringify(phoneData));
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                }
            });
        } else {
            window.sessionStorage.removeItem("phoneData");
        }
    }

    $.ajax({
        type: 'post',
        // url: root.replaceInter.replace_showOrderPageInfo,
        url: root.replaceInter.replace_showOrderPageInfo,
        dataType: 'json',
        data: window.sessionStorage.getItem("customerInfo"),//需要将当前的对象转换为json字符串,
        contentType: 'application/json',
        success: function (data) {
            shipAdd = data;
            // console.log(JSON.stringify(shipAdd));

            if (data.errorCode == 0) {
                pageData = data;
                $("#yunfei").html((Number(data.freight)).toFixed(2)); //运费
                if (data.freight == 0) {
                    var change = $("#changeFreight");
                    change.attr("disabled", "disabled");
                    change.attr("disabled", "disabled");
                    change.css({'background': '#999', 'borderColor': '#999', 'color': '#fff'});
                }
                $("#yunfei-init").html((Number(data.freight)).toFixed(2))
                $("#yunfei-beforeChange").html($("#yunfei").html());//保存之前的运费
                $(".good_total_price").html(Number(data.goodTotalMoney).toFixed(2)); //商品总价
                $(".goods_total_count").html(parseInt(data.skuTotalNum)); //总商品数量
                $(".pay_total_price").html(data.payTotalMoney); //应付总额

                $(".pattern_of_payment").html(data.payModel.payName); //支付方式
                $(".pattern_of_payment").attr("id", data.payModel.payType);
                tradeUuid = data.tradeUuid;

                if (data.payModel.payName == "账期支付") {
                    $(".credit_limit").html("可用授信额度：¥" + data.favailable); //授信额度
                    if (data.needApproval == true) {
                        $(".needApproval").html("需要审批");
                        $(".isHavePass").hide();
                    } else {
                        $(".needApproval").html("无需审批");
                        $(".isHavePass").hide();
                    }
                } else {
                    $(".credit_limit").hide()
                    if (data.needApproval == true) {
                        $(".needApproval").html("需审批、结算确认");
                        $(".isHavePass").hide();
                    } else {
                        $(".needApproval").html("不需审批、结算确认");
                        $(".isHavePass").hide();
                    }
                }


                if (data.shoppingAddList != null) {
                    console.log(data.shoppingAddList);
                    if (data.shoppingAddList.length > 0) {
                        var optionstring = "";
                        addressList = data.shoppingAddList;
                        for (var i = 0; i < addressList.length; i++) {
                            if (addressList.length < 2) {
                                $(".Unfold").hide()
                            }
                            var obj = addressList[i];
                            var streetName = '';
                            if (obj.street_id == 0) {
                                obj.streetName = streetName;
                            }
                            //----------名字拼接显示开始-----------
                            var nameList = "";
                            var moblieList = "";

                            var PersonList = obj.addressPersonList;
                            if (PersonList != null && PersonList.length > 0) {
                                for (var j = 0; j < PersonList.length; j++) {
                                    if (PersonList.length > 1) {
                                        nameList += PersonList[j].receiverName + ";";//姓名拼接
                                        var mobile = PersonList[j].mobile;
                                        moblieList = mobile.substr(0, 3) + "XXXX" + mobile.substr(7) + " ...";
                                    } else {
                                        nameList += PersonList[j].receiverName;//姓名拼接
                                        var mobile = PersonList[j].mobile;
                                        moblieList = mobile.substr(0, 3) + "XXXX" + mobile.substr(7);
                                    }

                                    var mobile = obj.addressPersonList[j].mobile;
                                    var receiverId = obj.addressPersonList[j].receiverId;
                                }
                                console.log(nameList);
                            }

                            if (obj.is_default == 1) {
                                optionstring += '<div class="mb-5 ml-20 addressSelected" style="float: left;position: relative; height: 30px;width: 90%;" onclick="selectAddress(this)"><span class="hide" id="addressname">' + obj.add_alias + '</span><span class="hidden"  id="use_name_str">' + linkman + '</span><span class="address_name"  id="usename" style="text-align: center;">' + nameList + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + obj.provinceName + '</span><span class="address_detail" id="addressdetail">' + obj.provinceName + obj.cityName + obj.areaName + obj.streetName + obj.detail_address + '</span><span class="user_phone" style="display:inline-block;line-height: 30px;color:#fff;background: #999;padding:0 5px;text-align: center;">默认地址</span><span class="hidden" id="addDetail">' + obj.detail_address + '</span><span class="hidden" id="celephone">' + mobile +'</span><span class="hide" id="receiverId">' + receiverId +'</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="DeleteAddress(this)" >删除</a></span></div>'
                            } else if (obj.is_default == 2 && i == 0) {
                                optionstring += '<div class="mb-5 ml-20 addressSelected" style="float: left;position: relative; height: 30px;width: 90%;" onclick="selectAddress(this)"><span class="hide" id="addressname">' + obj.add_alias + '</span><span class="hidden"  id="use_name_str">' + linkman + '</span><span class="address_name"  id="usename" style="text-align: center;">' + nameList + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + obj.provinceName + '</span><span class="address_detail" id="addressdetail">' + obj.provinceName + obj.cityName + obj.areaName + obj.streetName + obj.detail_address + '</span><span class="user_phone" id="userphone">' + moblieList + '</span><span class="hidden" id="addDetail">' + obj.detail_address + '</span><span class="hidden" id="celephone">' + mobile +'</span><span class="hide" id="receiverId">' + receiverId +'</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="DeleteAddress(this)" >删除</a></span></div>'
                            } else {
                                optionstring += '<div class="mb-5 ml-20" style="float: left;position: relative; height: 30px;width: 90%;" onclick="selectAddress(this)"><span class="hide" id="addressname">' + obj.add_alias + '</span><span class="hidden"  id="use_name_str">' + linkman + '</span><span class="address_name"  id="usename" style="text-align: center;">' + nameList + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + obj.provinceName + '</span><span class="address_detail" id="addressdetail">' + obj.provinceName + obj.cityName + obj.areaName + obj.streetName + obj.detail_address + '</span><span class="user_phone" id="userphone">' + moblieList + '</span><span class="hidden" id="addDetail">' + obj.detail_address + '</span><span class="hidden" id="celephone">' + mobile +'</span><span class="hide" id="receiverId">' + receiverId +'</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="DeleteAddress(this)" >删除</a></span></div>'
                            }

                        }
                        $(".address_info").html("<div id='ss' style='color: #cc0000'></div>" + optionstring);
                    }
                } else {
                    $(".Unfold").hide();
                    $(".address_info").html("<a onclick='addAddress()' class='f-12'>+添加新地址</a>");
                }


                /* 支付方式 */
                payModel = data.payModel;
                renderGoodsList(data, false);//商品列表渲染函数
                if (data.couponSpuSkuBoList != null) {
                    renderCoupon(data);//优惠券渲染函数
                } else {
                    $(".coupon").hide();
                    $(".coupon_info").hide()
                }

                console.log(addressList)
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
        }
    });

}

// 备注编辑框限制字数
limitImport('.change_freight_comment', 20);
limitImport('.comment', 100);


/**
 * textarea 限制输入字数
 * @param  string str 类名或ID
 * @param  number num 限制输入的字数
 */
function limitImport(str, num) {
    $(document).on('input propertychange', str, function () {
        var self = $(this);
        var content = self.val();
        if (content.length > num) {
            self.val(content.substring(0, num));
        }
        self.siblings('span').text(self.val().length + '/' + num);
    });
}

/*-------------------------------------------根据输入的存档电话进行验证开始------------------------------------*/
function upperCase() {
    if (document.getElementById("phonenumber").value != "") {
        $("#qingchu1").removeClass("yincang");
    }
}

function qingchu() {
    document.getElementById("phonenumber").value = "";
    $("#qingchu1").addClass("yincang");
    $("#verifyState ").remove();
    customerPhoneExist = "";
}

$(".yanzheng").click(function () {
    var canCheck = false;
    var phone = $(".verify_phone").val();
    if (phone == "") {
        layer.msg('请输入联系电话进行验证！', {icon: 5, time: 2000});
    }
    if (phone.length > 15) {
        $.Huimodalalert("请输入正确的手机号", 2000);
        canCheck = false;
    } else {
        canCheck = true;
    }
    if (canCheck == true) {

        var phone_data = {
            mobilePhone: phone,
            customerCode: customerInfo.customerCode
        };
        $.ajax({
            type: 'post',
            url: root.replaceInter.replace_adminCheckArchivalPhone,
            dataType: 'json',
            data: phone_data,//需要将当前的对象转换为json字符串,
            success: function (data) {
                if (data.errorCode == 0) {
                    customerPhoneExist = 10;
                    $("#verify").html("<div id='verifyState' class='verify yes'><span style='margin-left: 25px'><img src='../../../img/smallsuccess.png' class='w-11 h-11'></span><span style='margin-left:-14px;color:#04BE02 '>是</span></div>")
                    window.sessionStorage.setItem("phoneData", JSON.stringify(phone_data));
                } else {
                    customerPhoneExist = 20;
                    $("#verify").html("<div id='verifyState' class='verify no'><span style='margin-left: 25px'><img src='../../../img/false.png' class='w-11 h-11' ></span><span style='margin-left:-14px '>否</span></div>")
                    window.sessionStorage.setItem("phoneData", JSON.stringify(phone_data));
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
            }
        });
    } else {
        $.Huimodalalert("请输入正确的手机号", 2000);
    }
});
/*-------------------------------------------根据输入的存档电话进行验证结束------------------------------------*/

/*-----------------------------------------提交订单开始-----------------------------------------*/
function commit(el) {
    console.log($(".addressSelected").find("#receiverId").html());
    console.log($("#receiverId").html());
    console.log("usename===" + $(".addressSelected").find("#use_name_str").html());
    console.log("celephone===" + $(".addressSelected").find("#celephone").html());
    console.log(linkman);
    $("#ss").html("");
    if (isIng) {
        $.Huimodalalert("请求已提交，请勿重复点击！", 2000);
        return false
    }
    isIng = true;
    shippingAddressModel = {
        receiverProvince: customerInfo.provinceId,
        receiverProvinceName: customerInfo.provinceName,
        receiverCity: customerInfo.cityId,
        receiverCityName: customerInfo.cityName,
        receiverArea: customerInfo.districtId,
        receiverAreaName: customerInfo.districtName,
        receiverTown: customerInfo.streetId,
        receiverTownName: customerInfo.streetName,
        addressAreaCode: customerInfo.districtId,
        receivedName: $(".addressSelected").find("#use_name_str").html(),
        receivedPhone: $(".addressSelected").find("#celephone").html(),
        receiverDetailAddress: $(".addressSelected").find("#addDetail").html(),
        customerEmail: $(".addressSelected").find("#customerEmail").html(),
        customerLandinePhone: $(".addressSelected").find("#customerLandlinePhone").html(),
        receiverDetailAddressAlias: $(".addressSelected").find("#addressname").html(),
        shipAddId: $(".addressSelected").find("#ship_add_id").html(),

        // secondReceivedName:$(".addressSelected").find("#secondReceivedName").html(),   //'备用授权收货人名称', (有 传递)
        //
        // secondReceivedMobile:$(".addressSelected").find("#secondReceivedMobile").html(),   //'备用授权收货人手机号', (有 传递)
        //
        // secondReceivedOffice:$(".addressSelected").find("#secondReceivedOffice").html().trim(),    //'备用授权收货人办公电话',(有 传递)

        receivedOffice: $(".addressSelected").find("#receivedOffice").html(),    //授权收货人办公电话,(有 传递)

        // secondConsigneeId:$(".addressSelected").find("#secondConsigneeId").html(),   //备用授权收货人id(有 传递)

        // firstConsigneeId:$(".addressSelected").find("#firstConsigneeId").html()   //授权收货人id(必传)
        firstConsigneeId: $(".addressSelected").find("#receiverId").html()   //授权收货人id(必传)


    };
    // console.log(shippingAddressModel.secondConsigneeId)
    if (shippingAddressModel.secondConsigneeId == "" || shippingAddressModel.secondConsigneeId == 0) {
        delete shippingAddressModel.secondConsigneeId;
        delete shippingAddressModel.secondReceivedName;
        delete shippingAddressModel.secondReceivedMobile;
        delete shippingAddressModel.secondReceivedOffice;
        delete shippingAddressModel.receivedOffice;
    }
    var order_data = {};

    var weight = $(".weight").html();
    weight = weight.substring(weight.indexOf("：") + 1, weight.indexOf("公"));
    console.log("总重量为：" + weight);
// Number($(".good_total_price").html() + $("#yunfei").html()).toFixed(2)
    /*地址参数拼装*/
    if (couponModel == null) {
        var usedCoupon = 20;
        order_data = {
            tradeUuid: tradeUuid,
            roleName: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
            memberId: customerInfo.memberId,
            accountType: customerInfo.accountType,
            customerCode: customerInfo.customerCode,
            cityId: customerInfo.cityId,
            customerId: customerInfo.customerId,
            loginAccount: customerInfo.customerLoginAccount,
            customerName: customerInfo.customerName,
            finalTotalAmount: Number(Number($(".good_total_price").html()) + Number($("#yunfei").html())).toFixed(2), //交易金额 商品金额+运费
            freight: $("#yunfei").html(), //当前运费(必填),
            goodTotalMoney: $(".good_total_price").html(),//商品金额
            goodTotalNum: $(".goods_total_count").html(),
            goodTotalWeight: weight,
            payModel: payModel,
            payMoney: $(".pay_total_price").html(),
            source: 50,
            usedCoupon: usedCoupon, //使用优惠券:10=>使用;20=>未使用 判断，优惠券框是否被选中
            modifiyFreight: $("#yunfei-afterChange").html(), //修改后的运费(非必填) 判断
            initShippingFee: $("#yunfei-init").html(), //修改前的运费(必填) 系统首次生成的运费
            modifiyFreightReason: $("#afterFare-remark").html(), //修改运费原因(修改后的运费有值时,这个必填) 判断
            boxId: customerInfo.boxId, //草稿箱id
            provinceId: customerInfo.provinceId,//省id
            remarks: $("#remarks").val(),//备注
            shippingAddressModel: shippingAddressModel,//地址
            dispatchBillModel: dispatchBillModel,//商品列表
            customerPhoneExist: customerPhoneExist,//客户在档电话验证是否存在标识 10=》是；20=》不是 (必填)
            customerPhone: $("#phonenumber").val(),//客户电话  (必填)
            accPeriodIsPwd: 20,//帐期支付时需要传递 : 有密码-->10 ,无密码-->20
        }
    } else if (couponModel != {}) {
        var usedCoupon = 10;
        order_data = {
            tradeUuid: tradeUuid,
            roleName: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
            memberId: customerInfo.memberId,
            accountType: customerInfo.accountType,
            customerCode: customerInfo.customerCode,
            cityId: customerInfo.cityId,
            customerId: customerInfo.customerId,
            loginAccount: customerInfo.customerLoginAccount,
            customerName: customerInfo.customerName,
            finalTotalAmount: Number(Number($(".good_total_price").html()) + Number($("#yunfei").html())).toFixed(2), //交易金额 商品金额+运费
            freight: $("#yunfei").html(), //当前运费(必填),
            goodTotalMoney: $(".good_total_price").html(),//商品金额
            goodTotalNum: $(".goods_total_count").html(),
            goodTotalWeight: weight,
            payModel: payModel,
            payMoney: $(".pay_total_price").html(),
            source: 50,
            usedCoupon: usedCoupon, //使用优惠券:10=>使用;20=>未使用 判断，优惠券框是否被选中
            modifiyFreight: $("#yunfei-afterChange").html(), //修改后的运费(非必填) 判断
            initShippingFee: $("#yunfei-init").html(), //修改前的运费(必填) 系统首次生成的运费
            modifiyFreightReason: $("#afterFare-remark").html(), //修改运费原因(修改后的运费有值时,这个必填) 判断
            boxId: customerInfo.boxId, //草稿箱id
            provinceId: customerInfo.provinceId,//省id
            remarks: $("#remarks").val(),//备注
            shippingAddressModel: shippingAddressModel,//地址
            dispatchBillModel: dispatchBillModel,//商品列表
            customerPhoneExist: customerPhoneExist,//客户在档电话验证是否存在标识 10=》是；20=》不是 (必填)
            customerPhone: $("#phonenumber").val(),//客户电话  (必填)
            accPeriodIsPwd: 20,//帐期支付时需要传递 : 有密码-->10 ,无密码-->20
            couponModel: couponModel,//优惠券列表
        }
    }

    var add = order_data.shippingAddressModel;
    if ((!add.receivedName) && (!add.receivedPhone) && (!add.receiverDetailAddress) && (!add.receiverDetailAddressAlias) && (!add.shipAddId)) {
        $.Huimodalalert("请填写收货地址", 2000);
        isIng = false;
        return false;
        console.log(1)
    }
    if ($("#phonenumber").val() == "" && $("#verify").html() == "") {
        $.Huimodalalert("请进行在档电话验证", 2000);
        isIng = false;
        return false;
        console.log(2)
    }
    /*--------------判断授信额度是否足够---------------*/
    /*if ($(".pattern_of_payment").html() == '账期支付') {
        if ($(".needApproval").html() == '无需审批') {
            $(".isHavePass").children("span").each(function () {
                if ($(this).context.childNodes[0].checked == true && $(this).context.innerText == '有密码') {
                    // console.log('无需审批，有密码，过验证');
                    var credit_limit = $(".credit_limit").html();
                    var credit = parseFloat(credit_limit.substring(credit_limit.indexOf("：") + 2));
                    var price = parseFloat($(".pay_total_price").html().substring(1));
                    if (credit - price <= 0 || credit == 0) {
                        $.Huimodalalert("该用户不能使用账期支付下单", 2000);
                        return false
                    }
                }
            });
        }
    }*/
    if ($(".pattern_of_payment").html() == '账期支付') {
        var credit_limit = $(".credit_limit").html();


        var credit = parseFloat(credit_limit.substring(credit_limit.indexOf("：") + 2));
        var price = parseFloat($(".pay_total_price").html().substring(1));
        if (credit - price <= 0 || credit == 0) {
            $.Huimodalalert("该用户不能使用账期支付下单", 2000);
            isIng = false;
            return false
        }
    }
    if (Number($("#zongjine").html()) == 0) {
        $.Huimodalalert("支付金额有误", 2000);
        isIng = false;
        return false
    }

    // $("#submitbutton").attr("disabled", "disabled")
    order_data.qualityFileRequired = $("#zzNeed").val();
    if (order_data.qualityFileRequired == 10) {
        order_data.fileCopies = $("#zzNum").val();
        order_data.originalFile = $("input[name='zzyy']:checked").val();
    }
    $.ajax({
        type: 'post',
        url: root.replaceInter.replace_saveAdminTradeInfo,
        dataType: 'json',
        data: JSON.stringify(order_data),//需要将当前的对象转换为json字符串,
        contentType: 'application/json',
        success: function (data) {
            console.log(data);
            if (data.errorCode == 0) {
                $.Huimodalalert("提交成功", 2000);
                var index = layer.open({
                    type: 2,
                    title: "下单成功",
                    content: "creatSuccess.html?orderId=" + data.orderId
                });
                layer.full(index);
            } else if (data.errorCode == "60") {
                /*降价标红处理*/
                isIng = false;
                $.Huimodalalert(data.tip, 2000);
                var trArr = $(".goods_table tr");
                for (var i = 0; i < trArr.length; i++) {
                    for (var j = 0; j < data.goodChangeSkuVoList.length; j++) {
                        if ($(trArr[i]).find("td")[5].innerHTML == data.goodChangeSkuVoList[j].skuId) {
                            trArr[i].style.background = "#ffe7e7";
                        }
                    }
                }
            } else if (data.errorCode == "61") {
                /*库存不足标红处理*/
                isIng = false;
                $("#noStock").modal("show");
                var trArr = $(".goods_table tr");
                for (var i = 0; i < trArr.length; i++) {
                    for (var j = 0; j < data.goodChangeSkuVoList.length; j++) {
                        if ($(trArr[i]).find("td")[5].innerHTML == data.goodChangeSkuVoList[j].skuId) {
                            trArr[i].style.background = "#ffe7e7";
                            $(trArr[i]).find("td")[4].innerHTML = "库存不足";
                            $(trArr[i]).find("td")[4].style.color = "red";
                        }
                    }
                }
            } else if (data.errorCode == "62") {
                /*失效标红处理*/
                isIng = false;
                invalidData = data.goodChangeSkuVoList;
                var trArr = $(".goods_table tr");
                for (var i = 0; i < trArr.length; i++) {
                    for (var j = 0; j < data.goodChangeSkuVoList.length; j++) {
                        if ($(trArr[i]).find("td")[5].innerHTML == data.goodChangeSkuVoList[j].skuId) {
                            trArr[i].style.background = "#ffe7e7";
                            $(trArr[i]).find("td")[4].innerHTML = "失效或下架";
                            $(trArr[i]).find("td")[4].style.color = "red";
                        }
                    }
                }
                $("#invalidOrCut_price").modal("show");
            } else if (data.errorCode == "511") {
                isIng = false;
                $("#ss").html('该授权收货人无效，请重新选择');


            } else if (data.errorCode == "63") {
                /*商品在该区域没有库存标红处理*/
                isIng = false;
                var trArr = $(".goods_table tr");
                for (var i = 0; i < trArr.length; i++) {
                    for (var j = 0; j < data.goodChangeSkuVoList.length; j++) {
                        if ($(trArr[i]).find("td")[5].innerHTML == data.goodChangeSkuVoList[j].skuId) {
                            trArr[i].style.background = "#ffe7e7";
                            $(trArr[i]).find("td")[4].innerHTML = "缺货";
                            $(trArr[i]).find("td")[4].style.color = "red";
                        }
                    }
                }
                $("#noStock").modal("show");
            } else {
                $.Huimodalalert(data.errorMessage, 2000);
                isIng = false;
            }

        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            isIng = false;
        }
    });
}

/*-----------------------------------------提交订单结束-----------------------------------------*/

/*------------------------------------库存不足提示弹框按钮函数开始----------------------------*/
function backModify() {
    var index = parent.layer.getFrameIndex(window.name);
    parent.layer.close(index);
}

/*------------------------------------库存不足提示弹框按钮函数结束----------------------------*/

/*------------------------------------降价失效提示弹框按钮函数开始----------------------------*/
function clearInvalidGoods() {
    for (var i = 0; i < invalidData.length; i++) {
        for (var j = 0; j < pageData.tradeBoxItems.length; j++) {
            if (invalidData[i].skuId == pageData.tradeBoxItems[j].skuId) {
                pageData.tradeBoxItems.splice(j, 1);
            }
        }
    }
    renderGoodsList(pageData, true);
    $("#invalidOrCut_price").modal("hide");
}

/*------------------------------------降价失效提示弹框按钮函数结束----------------------------*/
/*-------------------------------------地址开始-------------------------------------------*/
var isSave; // 1 ==> 是修改地址   2 ==> 是添加地址
//编辑地址弹框
function EditAddress(addressBox) {
    //每次进来先清空一下
    $("#consigneename").val("");
    $("#consigneetelephone").val("");
    $("#addressList").empty();

    var handStr = "";
    console.log(handStr)
    console.log($("#ship_add_id").html())
    $("#dizhi").modal("show");
    $(".addressTitle").html("编辑收货地址");
    // $("#linkman").empty();
    // $("#secondLinkman").empty();
    var linkman = "";
    var moblie = "";
    $("#a").empty();
    $("#b").empty();
    var firstnameId;
    var secondnameId;
    // 查看地址信息
    data = {
        shipAddId: $("#ship_add_id").html(),
        memberId: customerInfo.memberId
    };
    var succCallBack = function (data, status, response) {
        console.log(data)
        if (data.errorCode == "1") {
            if (null != data.shippingAddress) {
                var ahipAdd = data.shippingAddress;
                // for (var i = 0; i < ahipAdd.length; i++) {
                var addressPersonArr = ahipAdd.addressPersonList;
                $("#addAlias").val(ahipAdd.add_alias);
                $("#detailedAddress").val(ahipAdd.detail_address);

                // linkman = ahipAdd.addressPersonList[0].receiver_name;
                // moblie = ahipAdd.addressPersonList[0].mobile;
                // firstnameId = data.memberShip.first_consignee_id;

                $("#linkman").val();
                $("#mobilephone").val();
                // if(moblie!="" && moblie!=null){
                // }
                $("#landlineCelephone").val(ahipAdd.office_phone);
                $("#email").val(ahipAdd.email);
                if (addressPersonArr.length > 0) {

                    for (var i = 0; i < addressPersonArr.length; i++) {
                        console.log("AAAAAAAA")
                        handStr += '<tr class="biaoge1">';
                        handStr += '<td class="biaoge1-1"><span id="consigneename" class="consigneename">姓名:' + addressPersonArr[i].receiver_name + '</span></td>';
                        handStr += '<td class="biaoge1-2"><span id="consigneetelephone" class="consigneetelephone">手机号码:' + addressPersonArr[i].mobile + '</span></td>';
                        handStr += '<td class="biaoge1-2"><span id="consignee_id" class="hide" >' + json[i].consignee_id + '</span></td>';
                        handStr += '<td class="biaoge1-2"><span id="authorized_consignee_id" class="hide" >' + json[i].authorized_consignee_id + '</span></td>';
                        handStr += '<td class="biaoge1-2"><span id="consignee_status" class="hide" >' + json[i].consignee_status + '</span></td>';
                        handStr += '<td class="biaoge1-2"><span id="ship_add_id" class="hide" >' + $("#ship_add_id").html() + '</span></td>';
                        handStr += '<td  onclick="Deletelinkman(this)"><a href="#">删除</a></td>';
                        handStr += '</tr>';
                    }
                    $("#tableid").find("table>tbody").append(handStr);
                    console.log(handStr)
                    handStr="";
                }
                // }

                // secondnameId = data.memberShip.second_consignee_id
                // $("#secondMobile").val(ahipAdd.second_mobile);
                // $("#secondLandlineCelephone").val(ahipAdd.second_office_phone);
            }
            // console.log(data.memberShip.second_receiver_name);
            // $("#addAlias").val(data.memberShip.add_alias);
            // $("#detailedAddress").val(data.memberShip.detail_address);
            // firstnameId = data.memberShip.first_consignee_id
            // $("#mobilephone").val(data.memberShip.mobile);
            // $("#landlineCelephone").val(data.memberShip.office_phone);
            // $("#email").val(data.memberShip.email);
            // secondnameId = data.memberShip.second_consignee_id
            // $("#secondMobile").val(data.memberShip.second_mobile);
            // $("#secondLandlineCelephone").val(data.memberShip.second_office_phone);
            // reloadAddress(root.replaceInter.replace_adminQueryAddressAfterUpdate)  //刷新地址列表  adminViewMemberShipPerson
            reloadAddress(root.replaceInter.replace_adminQueryAddressPerson)  //刷新地址列表  adminViewMemberShipPerson

        }

    };
    // web.doAjax(root.replaceInter.replace_adminQueryMemberShipPerson, 'post', data, succCallBack);
    //" http://192.168.0.107:36060/amembership/adminViewMemberShipPerson.jhtml"
    web.doAjax(root.replaceInter.replace_adminViewMemberShipPerson, 'post', data, succCallBack);
    // 查询收货人
    data = {
        customerCode: customerInfo.customerCode
    };
    var succCallBack = function (data, status, response) {
        if (data.errorCode == "0") {
            json = data.consignee;
            console.log(json)
            var optionstring = "<option value='' selected style='display:none;'>请选择授权收货人</option>";
            for (var i = 0; i < json.length; i++) {
                optionstring += "<option value='" + json[i].authorized_consignee_id + "'>" + json[i].consignee_name + "</option>"
                g = json[i];
            }
            console.log(optionstring)
            $("#linkman").html(optionstring);
            $("#secondLinkman").html(optionstring);

            $("#linkman").val(firstnameId);
            console.log(firstnameId)
            console.log(secondnameId)
            $("#secondLinkman").val(secondnameId);

        }
    };
    web.doAjax(root.replaceInter.replace_getConsigneeByCustomerCode, 'post', data, succCallBack);

    $("#provinceName").html(customerInfo.provinceName);
    $("#cityName").html(customerInfo.cityName);
    $("#countyName").html(customerInfo.districtName);
    $("#villageName").html(customerInfo.streetName);
    $("#provinceId").html(customerInfo.provinceId);
    $("#cityId").html(customerInfo.cityId);
    $("#countyId").html(customerInfo.districtId);
    $("#villageId").html(customerInfo.streetId);

    /*$(".addAlias").val($(addressBox.parentElement.parentElement).find("#addressname")[0].innerHTML);
    $(".detailedAddress").val($(addressBox.parentElement.parentElement).find("#addDetail")[0].innerHTML);
    $("#mobilephone").val($(addressBox.parentElement.parentElement).find("#celephone")[0].innerHTML);*/
    isSave = 1;
}

// function reload(){
//     var address_data = {
//         memberId: customerInfo.memberId,
//         pageNum:1,
//         pageSize:20,
//         provinceId: customerInfo.provinceId,
//         cityId: customerInfo.cityId,
//         districtId: customerInfo.districtId,
//         streetId: customerInfo.streetId,
//         type:20,
//     };
//     var succCallBack = function (data, status, response) {
//         if (data.errorCode == "0") {
//             var optionstring = "";
//             console.log(data)
//             addressList = data.list;
//             var arr = new Array();
//
//             for (var i = 0; i < data.list.length; i++) {
//
//                 /*if(i == 0){
//                     optionstring += '<div class="mb-5 ml-20 addressSelected" style="float: left;position: relative;" onclick="selectAddress(this)"><span class="address_name" id="addressname">' + obj.add_alias + '</span><span class="user_name"  id="usename" style="margin-left: 50px">' + obj.linkman + '</span><span class="address_detail"  id="addressdetail" style="margin-left: 50px">' + obj.detail_address + '</span><span class="user_phone" id="userphone" style="margin-left: 50px">' + obj.mobile + '</span><span class="hide" id="receiverId">' + obj.addressPersonList[i].receiverId+ '</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a></span></div>'
//                 }else {
//                     optionstring += '<div class="mb-5 ml-20" style="float: left;position: relative;" onclick="selectAddress(this)"><span class="address_name" id="addressname" style="margin-right: 0">' + obj.add_alias + '</span><span class="user_name"  id="usename" style="margin-left: 50px">' + obj.linkman + '</span><span class="address_detail"  id="addressdetail" style="margin-left: 50px">' + obj.detail_address + '</span><span class="user_phone" id="userphone" style="margin-left: 50px">' + obj.mobile + '</span><span class="hide" id="receiverId">' + obj.addressPersonList[i].receiverId+ '</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a></span></div>'
//                 }*/
//                 /*optionstring += '<div class="mb-5 ml-20" style="float: left;position: relative;" onclick="selectAddress(this)"><span class="address_name" id="addressname" style="margin-right: 0">' + obj.add_alias + '</span><span class="user_name"  id="usename" style="margin-left: 50px">' + obj.linkman + '</span><span class="address_detail"  id="addressdetail" style="margin-left: 50px">' + obj.detail_address + '</span><span class="user_phone" id="userphone" style="margin-left: 50px">' + obj.mobile + '</span><span class="hide" id="receiverId">' + obj.addressPersonList[i].receiverId+ '</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a></span></div>'*/
//
//                 if (data.list.length < 2) {
//                     $(".Unfold").hide()
//                 }
//                 var obj = data.list[i];
//                 var streetName = '';
//                 if (obj.street_id == 0) {
//                     obj.streetName = streetName;
//                 }
//                 arr = obj.addressPersonList;
//                 console.log(arr[0].receiverName)
//                 var mobile = obj.addressPersonList[0].mobile;
//                 console.log(arr[0].mobile)
//                 console.log(obj.is_default)
//                 // var mobile = obj.mobile;
//                 var sub = mobile.substr(3, 4);
//                 mobile = mobile.replace(sub, 'XXXX');
//
//                 console.log("33333333333")
//                 console.log(optionstring)
//                 optionstring += '<div class="mb-5 ml-20" style="height: 80px;float: left;position: relative;""><span class="hide" id="addressname">' + obj.add_alias + '</span><span class="user_name"  id="usename">' + obj.addressPersonList[0].receiverName + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + obj.provinceName + '</span><span class="address_detail"  id="addressdetail">' + obj.provinceName + obj.cityName + obj.areaName + obj.streetName + obj.detail_address + '</span><span class="user_phone" id="userphone">' + mobile + '</span><span class="hidden" id="celephone">' + mobile + '</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span style="margin-right:47px; float:right">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="DeleteAddress(this)" >删除</a></span></div>'
//
//                 alert(optionstring)
//             }
//             $(".address_info").html("<div id='ss' style='color: #cc0000'></div>"+optionstring);
//         } else {
//             $.Huimodalalert(data.errorMessage, 2000);
//         }
//     };
//     web.doAjax(url, 'post', address_data, succCallBack);
// }
var addmobile = "";
var addlink = "";
var cc = 0;

//添加地址弹框
function addAddress() {
    console.log("进入添加地址弹框");
    $("#dizhi").modal("show");
    $(".addressTitle").html("新增收货地址");
    $("#addressList").empty();

    addlink = "";
    addmobile = "";
    $("#linkman").empty();
    $("#secondLinkman").empty();
    $("#a").empty();
    $("#b").empty();
    // 查询收货人
    data = {
        customerCode: customerInfo.customerCode
    }
    var succCallBack = function (data, status, response) {
        if (data.errorCode == "0") {
            json = data.consignee;
            var optionstring = "<option value='' selected style='display:none;'>请选择授权收货人</option>";
            for (var i = 0; i < json.length; i++) {
                optionstring += "<option value='" + json[i].authorized_consignee_id + "'>" + json[i].consignee_name + "</option>"
                g = json[i];
            }
            $("#linkman").html(optionstring);
            $("#secondLinkman").html(optionstring);


        }
    }
    web.doAjax(root.replaceInter.replace_getConsigneeByCustomerCode, 'post', data, succCallBack);
    $("#provinceName").html(customerInfo.provinceName);
    $("#cityName").html(customerInfo.cityName);
    $("#countyName").html(customerInfo.districtName);
    $("#villageName").html(customerInfo.streetName);
    $("#provinceId").html(customerInfo.provinceId);
    $("#cityId").html(customerInfo.cityId);
    $("#countyId").html(customerInfo.districtId);
    $("#villageId").html(customerInfo.streetId);

    $(".addAlias").val("");
    $(".detailedAddress").val("");
    $("#linkman").val("");
    $("#mobilephone").val("");
    $("#landlineCelephone").val("");

    isSave = 2;
}

/*保存收货地址*/
function saveAddress() {
    console.log($("#linkman option:selected").text());
    console.log($("#mobilephone").val());

    if (isSave == 1) { //编辑地址
        // $("#mobilephone").val("");//dsadsadsadas
        //编辑地址
        var arr = [];
        $('#tableid tbody tr').each(function (i, dom) {
            if ('' == $(dom).find(0).text()) {
                console.log("1111")
                arr.push({
                    "name": $(dom).find('.consigneename').text().split(":")[1],
                    "mobile": $(dom).find('.consigneetelephone').text().split(":")[1] == "---" ? "" : $(dom).find('.consigneetelephone').text().split(":")[1],
                    "receiverId": $(dom).find('#consignee_id').text(),
                    "id": $(dom).find('#authorized_consignee_id').text(),
                    "status": $(dom).find('#consignee_status').text(),
                    "addressId": 0,
                });
            } else {
                console.log("2222")
                arr.push({
                    "name": $(dom).find('.consigneename').text().split(":")[1],
                    "mobile": $(dom).find('.consigneetelephone').text().split(":")[1] == "---" ? "" : $(dom).find('.consigneetelephone').text().split(":")[1],
                    "receiverId": $(dom).find('#consignee_id').text(),
                    "id": $(dom).find('#authorized_consignee_id').text(),
                    "status": $(dom).find('#consignee_status').text(),
                    "addressId": $(dom).find(0).text(),
                });

            }
        });
        console.log(JSON.stringify(arr))
        var address_data = {
            provinceId: $("#provinceId").html(),
            cityId: $("#cityId").html(),
            districtId: $("#countyId").html(),
            streetId: $("#villageId").html(),
            detailAddress: $("#detailedAddress").val(),
            addAlias: $("#addAlias").val(),
            officePhone: $("#landlineCelephone").val(),
            email: $("#email").val(),
            memberId: customerInfo.memberId,
            shipAddPersonJson: JSON.stringify(arr),
            shipAddId: $("#ship_add_id").html(),
            linkman: $("#linkman").val(),
            mobile: $("#mobilephone").val(),
            firstConsigneeId: $(".addressSelected").find("#firstConsigneeId").html()

            // secondConsigneeId: $("#secondLinkman").val(),
            // linkman: $("#linkman option:selected").text(),
            // secondReceiverName:$("#secondLinkman option:selected").text(),
            // secondMobile:$("#secondMobilephone").val(),
            // secondOfficePhone: $("#secondLandlineCelephone").val(),

            /*oldFirstConsigneeName:$("#linkman option:selected").val(), //旧的第一收货人名称
            oldFirstConsigneeMobile: $("#mobilephone").val(),//旧的第一收货人手机号
            oldFirstConsigneeOfficePhone:$("#landlineCelephone").val(),   //旧的第一收货人办公电话
            oldSecondConsigneeName:$("#secondLinkman option:selected").val(),   //旧的第二收货人名称
            oldSecondConsigneeMobile: $("#secondMobilephone").val() , //旧的第二收货人手机号
            oldSecondConsigneeOfficePhone:$("#secondLandlineCelephone").val(),//旧的第二收货人办公电话
*/

        };
        var succCallBack = function (data, status, response) {
            console.log("编辑地址成功" + data.errorCode);
            if (data.errorCode == "0") {
                $.Huimodalalert('编辑地址成功', 2000);
                getInfo();
                reloadAddress(root.replaceInter.replace_adminQueryAddressPerson)  //刷新地址列表
                $("#dizhi").modal("hide");
            } else if (data.errorCode == "308") {
                isIng = false;
                $("#a").html('该授权收货人无效，请重新选择');
            } else if (data.errorCode == "302") {
                isIng = false;
                $("#b").html('收货人手机号重复，请重新选择');
            } else {
                $.Huimodalalert(data.errorMessage, 2000);
            }
        };
        /*
                root.replaceInter.replace_adminUpdateMemberShoppingAddress    192.168.0.107:36060/amembership/adminUpdateMemberShoppingAddress.jhtml
        */
        web.doAjax(root.replaceInter.replace_adminUpdateMemberShoppingAddress, 'post', address_data, succCallBack);
    } else if (isSave == 2) {
        //添加新地址
        console.log($("#linkman").val())
        console.log(addlink)
        console.log(addmobile)
        var arr = [];
        $('#tableid tbody tr').each(function (i, dom) {
            if ('' == $(dom).find(0).text()) {
                console.log("AAAA");
                arr.push({
                    // "name": $(dom).find('.consigneename').text(),
                    // "mobile": $(dom).find('.consigneetelephone').text(),
                    "name": $(dom).find('.consigneename').text().split(":")[1],
                    "mobile": $(dom).find('.consigneetelephone').text().split(":")[1] == "---" ? "" : $(dom).find('.consigneetelephone').text().split(":")[1],
                    "receiverId": $(dom).find('#consignee_id').text(),
                    "id": $(dom).find('#authorized_consignee_id').text(),
                    "status": $(dom).find('#consignee_status').text(),
                    "addressId": 0,
                });
            } else {
                console.log("BBBB");
                arr.push({
                    "name": $(dom).find('.consigneename').text().split(":")[1],
                    "mobile": $(dom).find('.consigneetelephone').text().split(":")[1] == "---" ? "" : $(dom).find('.consigneetelephone').text().split(":")[1],
                    "receiverId": $(dom).find('#consignee_id').text(),
                    "id": $(dom).find('#authorized_consignee_id').text(),
                    "status": $(dom).find('#consignee_status').text(),
                    "addressId": $(dom).find(0).text(),
                });
            }
        });
        console.log(JSON.stringify(arr))
        var address_data = {
            provinceId: $("#provinceId").html(),
            cityId: $("#cityId").html(),
            districtId: $("#countyId").html(),
            streetId: $("#villageId").html(),
            detailAddress: $("#detailedAddress").val(),
            // linkman: $("#linkman option:selected").text(),
            linkman: $("#linkman").val(),
            mobile: addmobile,
            addAlias: $("#addAlias").val(),
            officePhone: $("#landlineCelephone").val(),
            email: $("#email").val(),
            memberId: customerInfo.memberId,
            shipAddPersonJson: JSON.stringify(arr),
            customerCode: customerInfo.customerCode
        };
        var succCallBack = function (data, status, response) {
            if (data.errorCode == "0") {
                $.Huimodalalert('添加地址成功', 2000);
                getInfo();
                // reloadAddress(root.replaceInter.replace_adminQueryAddressAfterAdd)//刷新地址列表
                reloadAddress(root.replaceInter.replace_adminQueryAddressPerson)//刷新地址列表
                $("#dizhi").modal("hide");
            } else if (data.errorCode == "308") {
                isIng = false;
                $("#a").html('授权收货人无效授权收货人，请重新选择');


            } else if (data.errorCode == "302") {
                isIng = false;
                $("#c").html('手机号不能重复');
            } else {
                $.Huimodalalert(data.errorMessage, 2000);
            }
        };
        //http://192.168.0.107:36060/amembership/adminAddMemberShoppingAddress.jhtml
        web.doAjax(root.replaceInter.replace_adminAddMemberShoppingAddress, 'post', address_data, succCallBack);
    }
}

/*添加或编辑之后重新加载地址列表函数*/
function reloadAddress(url) {
    var address_data = {
        memberId: customerInfo.memberId,
        pageNum: 1,
        pageSize: 20,
        provinceId: customerInfo.provinceId,
        cityId: customerInfo.cityId,
        districtId: customerInfo.districtId,
        streetId: customerInfo.streetId,
        type: 20,
    };
    var succCallBack = function (data, status, response) {
        if (data.errorCode == "0") {
            var optionstring = "";
            console.log(data)
            addressList = data.list;
            for (var i = 0; i < data.list.length; i++) {
                /*if(i == 0){
                    optionstring += '<div class="mb-5 ml-20 addressSelected" style="float: left;position: relative;" onclick="selectAddress(this)"><span class="address_name" id="addressname">' + obj.add_alias + '</span><span class="user_name"  id="usename" style="margin-left: 50px">' + obj.linkman + '</span><span class="address_detail"  id="addressdetail" style="margin-left: 50px">' + obj.detail_address + '</span><span class="user_phone" id="userphone" style="margin-left: 50px">' + obj.mobile + '</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a></span></div>'
                }else {
                    optionstring += '<div class="mb-5 ml-20" style="float: left;position: relative;" onclick="selectAddress(this)"><span class="address_name" id="addressname" style="margin-right: 0">' + obj.add_alias + '</span><span class="user_name"  id="usename" style="margin-left: 50px">' + obj.linkman + '</span><span class="address_detail"  id="addressdetail" style="margin-left: 50px">' + obj.detail_address + '</span><span class="user_phone" id="userphone" style="margin-left: 50px">' + obj.mobile + '</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a></span></div>'
                }*/
                /*optionstring += '<div class="mb-5 ml-20" style="float: left;position: relative;" onclick="selectAddress(this)"><span class="address_name" id="addressname" style="margin-right: 0">' + obj.add_alias + '</span><span class="user_name"  id="usename" style="margin-left: 50px">' + obj.linkman + '</span><span class="address_detail"  id="addressdetail" style="margin-left: 50px">' + obj.detail_address + '</span><span class="user_phone" id="userphone" style="margin-left: 50px">' + obj.mobile + '</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a></span></div>'*/

                if (data.list.length < 2) {
                    $(".Unfold").hide()
                }
                var obj = data.list[i];
                var streetName = '';
                if (obj.street_id == 0) {
                    obj.streetName = streetName;
                }
                for (var j = 0; j < obj.addressPersonList.length; j++) {
                    //-----------------------------开始---------------------------
                    //-----------------------------结束---------------------------
                    var personList = obj.addressPersonList;
                    var linkman = personList[j].receiverName;
                    var mobile = personList[j].mobile;
                    // var mobile = obj.mobile;
                    var sub = mobile.substr(3, 4);
                    mobile = mobile.replace(sub, 'XXXX');
                    if (obj.is_default == 1) {
                        optionstring += '<div class="mb-5 ml-20 addressSelected" style="height: 80px;float: left;position: relative;" onclick="selectAddress(this)"><span class="hide" id="addressname">' + obj.add_alias + '</span><span class="hidden"  id="use_name_str">' + linkman + '</span><span class="user_name"  id="usename">' + linkman + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + obj.provinceName + '</span><span class="address_detail"  id="addressdetail">' + obj.provinceName + obj.cityName + obj.areaName + obj.streetName + obj.detail_address + '</span><span class="user_phone" id="userphone">' + mobile + '</span><span class="hide" id="receiverId">' + personList[j].receiverId + '</span><span class="hidden" id="addDetail">' + obj.detail_address + '</span><span class="hidden" id="celephone">' + personList[j].mobile + '</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="DeleteAddress(this)" >删除</a></span></div>'
                    } else if (obj.is_default != 1 && i == 0) {
                        optionstring += '<div class="mb-5 ml-20 addressSelected" style="height: 80px;float: left;position: relative;" onclick="selectAddress(this)"><span class="hide" id="addressname">' + obj.add_alias + '</span><span class="hidden"  id="use_name_str">' + linkman + '</span><span class="user_name"  id="usename">' + linkman + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + obj.provinceName + '</span><span class="address_detail"  id="addressdetail">' + obj.provinceName + obj.cityName + obj.areaName + obj.streetName + obj.detail_address + '</span><span class="user_phone" id="userphone">' + mobile + '</span><span class="hide" id="receiverId">' + personList[j].receiverId + '</span><span class="hidden" id="addDetail">' + obj.detail_address + '</span><span class="hidden" id="celephone">' + personList[j].mobile + '</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="DeleteAddress(this)" >删除</a></span></div>'
                    } else if (obj.is_default == 2) {
                        console.log("33333333333")
                        optionstring += '<div class="mb-5 ml-20" style="height: 80px;float: left;position: relative;" onclick="selectAddress(this)"><span class="hide" id="addressname">' + obj.add_alias + '</span><span class="hidden"  id="use_name_str">' + linkman + '</span><span class="user_name"  id="usename">' + linkman + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + obj.provinceName + '</span><span class="address_detail"  id="addressdetail">' + obj.provinceName + obj.cityName + obj.areaName + obj.streetName + obj.detail_address + '</span><span class="user_phone" id="userphone">' + mobile + '</span><span class="hide" id="receiverId">' + personList[j].receiverId + '</span><span class="hidden" id="addDetail">' + obj.detail_address + '</span><span class="hidden" id="celephone">' + personList[j].mobile + '</span><span class="hide" id="ship_add_id">' + obj.ship_add_id + '</span><span class="hide" id="customerEmail">' + obj.email + '</span><span class="hide" id="customerLandlinePhone">' + obj.office_phone + '</span><span style="margin-right:47px; float:right"><a onclick="EditAddress(this)" >编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="DeleteAddress(this)" >删除</a></span></div>'
                    }
                }
            }
            $(".address_info").html("<div id='ss' style='color: #cc0000'></div>" + optionstring);
        } else {
            $.Huimodalalert(data.errorMessage, 2000);
        }
    };
    web.doAjax(url, 'post', address_data, succCallBack);
}

/*-------------------------------------地址结束-------------------------------------------*/

//校验添加的收货人名字和手机号
function checkName() {
    var flag = true;
    var arr = [];
    $('#tableid tbody tr').each(function (i, dom) {
        arr.push({
            "name": $(dom).find('.consigneename').text().split(":")[1],
            "mobile": $(dom).find('.consigneetelephone').text().split(":")[1] == "---" ? "" : $(dom).find('.consigneetelephone').text().split(":")[1],
        });
        console.log(arr);
        //手机号码和姓名不能重复
        for (var i = 0; i < arr.length; i++) {
            if (arr[i].name == $("#linkman").val()) {
                $.Huimodalalert('该收货人已存在', 2000);
                console.log("该收货人已存在");
                flag = false;
            }
            if ($("#mobilephone").val().length > 0 && arr[i].mobile == $("#mobilephone").val()) {
                $.Huimodalalert('该手机号码已存在', 2000);
                flag = false;
            }
        }
        if (arr.length >= 10) {
            $.Huimodalalert('最多可添加10个收货人', 2000);
            flag = false;
        }

    });
    return flag;
}

//添加收货人名字和手机号
function addlinkman(id, ce) {

    console.log("进入添加收货人");
    console.log($("#landlineCelephone").val());
    var reg = /^1\d{10}$/;
    if($("#linkman").val().replace(/^ +| +$/g,'')==''){
        $.Huimodalalert('收货人姓名不能为空', 2000);
    }
    if ($("#linkman").val().length <= 0) {   //验证收货人姓名不能为空
        $.Huimodalalert('收货人姓名不能为空', 2000);
        return false;
    } else if ($("#linkman").val().length == 1) {
        $.Huimodalalert('收货人姓名最少为两位', 2000);
        return false;

    } else if ($("#linkman").val().length > 5) {
        $.Huimodalalert('收货人姓名最多为五位', 2000);
        return false;
    }
    if ($("#mobilephone").val().length > 0 && ($("#mobilephone").val().length < 11 || !reg.test($("#mobilephone").val()))) {
        $.Huimodalalert('收货人手机号格式不正确', 2000);
        return;
    }
    checkName();
    // console.log(checkName());

    if (checkName() == true && $("#linkman").val() != null && $("#linkman").val() != '') {
        data = {
            customerCode: customerInfo.customerCode
        }
        var succCallBack = function (data, status, response) {
            /*var value = $('#linkman').val();*/
            addlink = $("#linkman").val();
            addmobile = $("input[name=mobilephone]").val();
           /* console.log(addmobile)
            console.log(addlink)*/
            var handStr = '';
            if (data.errorCode == "0") {
                var json = data.consignee;
                console.log(json)
                for (var i = 0; i < json.length; i++) {
                    if (json[i].consignee_name == linkman) {
                        console.log(11111)
                        // console.log(json[i].consignee_name)
                        // console.log(json[i].consignee_id)
                        // console.log(json[i].authorized_consignee_id)
                        // console.log()
                        handStr += '<tr class="biaoge1">';
                        handStr += '<td style=" text-align: left;"  class="" ><span id="" class="consigneename">' + json[i].consignee_name + '</span></td>';
                        handStr += '<td style=" text-align: center;"  class=""><span id="" class="consigneetelephone">' + json[i].consignee_telephone + '</span></td>';
                        handStr += '<td class=""><span id="consignee_id" class="hide" >' + json[i].consignee_id + '</span></td>';
                        handStr += '<td class=""><span id="authorized_consignee_id" class="hide" >' + json[i].authorized_consignee_id + '</span></td>';
                        handStr += '<td class=""><span id="consignee_status" class="hide" >' + json[i].consignee_status + '</span></td>';
                        handStr += '<td class=""><span id="ship_add_id" class="hide" >' + $("#ship_add_id").html() + '</span></td>';
                        handStr += '<td style=" text-align: center;"   onclick="Deletelinkman(this)"><a href="#">删除</a></td>';
                        handStr += '</tr>';

                    } else if (json[i].consignee_name != linkman) {
                        console.log(2222)
                        handStr += '<tr style="margin-left: 30px" class="biaoge1" id="linkManId">';
                        handStr += '<td  class="biaoge1-1" style=" text-align: left;"><span id="consigneename" class="consigneename">姓名:' + addlink + '</span></td>';
                        if (($("#linkman").val() != null || $("#linkman").val() != '') && ($("#mobilephone").val() == "" || $("#mobilephone").val() == null)) {
                            handStr += '<td style="margin-left: 10px;display:block;" class="biaoge1-2"><span style="padding-left: 22px;" id="" class="consigneetelephone">手机号码:' + '---' + '</span></td>';
                        } else {
                            handStr += '<td style=" text-align: center;" class="biaoge1-2"><span style="text-align: center;display:block;" id="" class="consigneetelephone">手机号码:' + addmobile + '</span></td>';
                        }
                        handStr += '<td class="biaoge1-2"><span id="consignee_id" class="hide" >' + json[i].consignee_id + '</span></td>';
                        handStr += '<td class="biaoge1-2"><span id="authorized_consignee_id" class="hide" >' + json[i].authorized_consignee_id + '</span></td>';
                        handStr += '<td class="biaoge1-2"><span id="consignee_status" class="hide" >' + json[i].consignee_status + '</span></td>';
                        handStr += '<td class="biaoge1-2"><span id="ship_add_id" class="hide" >' + $("#ship_add_id") + '</span></td>';
                        handStr += '<td style="padding-left: 22px;"  onclick="Deletelinkman(this)"><a  href="#">删除</a></td>';
                        handStr += '</tr>';
                        break;

                    }
                }
                $("#tableid").find("table>tbody").append(handStr);
                $("#linkman").val('');
                $("input[name=mobilephone]").val('');
            }
        }
        web.doAjax(root.replaceInter.replace_getConsigneeByCustomerCode, 'post', data, succCallBack);


        $("#provinceName").html(customerInfo.provinceName);
        $("#cityName").html(customerInfo.cityName);
        $("#countyName").html(customerInfo.districtName);
        $("#villageName").html(customerInfo.streetName);
        $("#provinceId").html(customerInfo.provinceId);
        $("#cityId").html(customerInfo.cityId);
        $("#countyId").html(customerInfo.districtId);
        $("#villageId").html(customerInfo.streetId);

        // $(".addAlias").val("");
        // $(".detailedAddress").val("");
        // $("#linkman").val("");
        // $("#mobilephone").val("");
        // $("#landlineCelephone").val("");
    }


}

//删除授权收货人
function Deletelinkman(k) {
    $(k).parent().remove();
}

//删除地址
function DeleteAddress() {
    console.log("ship_add_id=" + $("#ship_add_id").html());
    data = {
        memberId: customerInfo.memberId,
        shipAddId: $("#ship_add_id").html()
    };
    var succCallBack = function (data, status, response) {
        if (data.errorCode == 1) {
            $.Huimodalalert('删除地址成功', 2000);
            getInfo();
            reloadAddress(root.replaceInter.replace_adminQueryAddressPerson)  //刷新地址列表
        }
    };
    //"http://192.168.0.107:36060/amembership/deleteMemberShoppingAddress.jhtml"
    web.doAjax(root.replaceInter.replace_deleteMemberShoppingAddress, 'post', data, succCallBack);

}

// var arr = [];
// $('#tableid tbody tr').each(function (i, dom) {
//     arr.push({"name": $(dom).find('.addName').text(), "phone": $(dom).find('.phone').text()});
// });
//
// console.log(JSON.stringify(arr));

function show() {
    console.log("ship_add_id=" + $("#ship_add_id").html());
    arr = shipAdd.shoppingAddList;
    console.log(arr);
    data = {
        memberId: customerInfo.memberId,
        shipAddId: $("#ship_add_id").html()

    };
    var succCallBack = function (data, status, response) {

        if (data.errorCode == 1) {
            $.Huimodalalert('删除地址成功', 2000);
            // xuanranliebiao();
            getInfo();
            reloadAddress(root.replaceInter.replace_adminQueryAddressAfterUpdate)  //刷新地址列表

        }
    };
    // web.doAjax(root.replaceInter.replace_adminQueryMemberShipPerson, 'post', data, succCallBack);
    //"http://192.168.0.107:36060/amembership/adminQueryAddressPerson.jhtml"
    web.doAjax(root.replaceInter.replace_adminQueryAddressPerson, 'post', data, succCallBack);
}



